/**
 * @version 3 11 February 2013
 * @author Myhaylo Kotsyuruba
 */

public abstract class ManyAnswersQuestions extends Question {
    private Answer[] answers;

    public ManyAnswersQuestions(String text, int score, Answer[] answers) {
        super(text, score);
        this.answers = answers;
    }
    
    @Override
    public String toString() {
        String question = getText();
        for (int index = 0; index < answers.length; index++) {
            String answer = String.format("%n  %d) %s", (index + 1),
                                                        answers[index].toString());
            question = question.concat(answer);
        }
        return question;
    }

    public Answer[] getAnswers() {
        Answer[] newAnswers = new Answer[answers.length];
        for (int index = 0; index < answers.length; index++) {
            newAnswers[index] = answers[index].clone();        }
        return newAnswers;
    }

    public int getQuantityAnswers() {
        return answers.length;
    }
    
    public boolean isCorrectAnswer(int index) {
        return answers[index].isCorrect();
    }
}
